package com.LC.Controller;

import com.LC.Constant.MessageConstant;
import com.LC.Entity.Result;
import com.LC.Entity.SetMeal;
import com.LC.Service.SetMealService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Meal")
public class MealController {

    @Reference
    SetMealService setMealService;

    @RequestMapping("/AllMeal")
    public Result findAllMeal(){
        List<SetMeal> allMeal;
        try {
            allMeal = setMealService.findAllMeal();
        }catch (Exception e){
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
        return new Result(true,MessageConstant.QUERY_SETMEALLIST_SUCCESS,allMeal);
    }

    @RequestMapping("/MealById")
    public Result findById(int id){
        SetMeal byId;
        try {
            byId = setMealService.findById(id);
        }catch (Exception e){
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
        return new Result(true,MessageConstant.GET_SETMEAL_LIST_SUCCESS,byId);
    }



}
